@layout("/common/_container.html"){
<style>.btnBox{background:#f1f1f1;position:fixed;bottom:0;width:100%;padding:5px 0;text-align:center;}.btnBox > button{margin:0;color:white;background:#2b6594;width:80px;font-size:1em;}.btnBox > button:last-of-type{background:white;border:1px solid #999999;color:inherit}#cardholder{padding:5px 20px;}#cardholder > div{display: flex;margin: 10px 0;}#cardholder > div > span{width: 80px;}</style>
<div style="display: none">
    <input type="hidden" id="customerIdValue" value="">
    <input type="hidden" id="phone" value="${customerInfo.customerPhone}">
    <input type="hidden" id="customerId" value="${customerInfo.id}">
    <input type="hidden" id="reservationsId" value="${customerInfo.reservationsId}">
</div>
<div class="ibox float-e-margins">
    <div style="background: #6090b8;color: white;padding: 5px 10px;">设置会员等级</div>
    <div id="cardholder">
        <div>
            <span>持卡人：</span>
            <div>${customerInfo.customerName}</div>
        </div>
        <div>
            <span>电话：</span>
            <div>${customerInfo.customerPhone}</div>
        </div>
        <div>
            <span>经办人</span>
            <div>${userName}</div>
        </div>
        <div>
            <span>会员卡号：</span>
            <div><input type="text" id="membersNum" autocomplete="off" maxlength="9" autocomplete="off" placeholder="请填写会员卡号" value=""></div>
        </div>
    </div>
    <div class="btnBox">
        <button class="btn" type="button" onclick="settingSure()">确定</button>
        <button class="btn" type="button" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name))">关闭
        </button>
    </div>
</div>
<script>
    settingSure = function () {//设置会员等级
        var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
        if (!myreg.test($("#phone").val().substring(0,11))) {
            if (confirm("手机号格式不正确，确定设置会员吗？")) {
                $.ajax({
                    url: Feng.ctxPath + "/consultant/settingMembersNum/" + $("#customerId").val() + "/" + $("#reservationsId").val() + "/" + $("#membersNum").val() + "/" + $("#phone").val(),
                    dataType: "json",
                    contentType: "application/json",
                    type: "POST",
                    success: function (data) {
                        if (data == 22) {
                            alert("修改会员卡号成功！");
                            window.parent.location.href = Feng.ctxPath + '/customerDetails/to_openBileLists/' + $("#customerId").val() + "/6";
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        } else {
                            alert("设置会员卡号操作成功！");
                            window.parent.location.href = Feng.ctxPath + '/customerDetails/to_openBileLists/' + $("#customerId").val() + "/6";
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        }
                    }
                });
            }
        }else{
            $.ajax({
                url: Feng.ctxPath + "/consultant/settingMembersNum/" + $("#customerId").val() + "/" + $("#reservationsId").val() + "/" + $("#membersNum").val() + "/" + $("#phone").val(),
                dataType: "json",
                contentType: "application/json",
                type: "POST",
                success: function (data) {
                    if (data == 22) {
                        alert("修改会员卡号成功！");
                        window.parent.location.href = Feng.ctxPath + '/customerDetails/to_openBileLists/' + $("#customerId").val() + "/6";
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    } else {
                        alert("设置会员卡号操作成功！");
                        window.parent.location.href = Feng.ctxPath + '/customerDetails/to_openBileLists/' + $("#customerId").val() + "/6";
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    }
                }
            });
        }
    };
</script>
@}